package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.eschool.model.Clas;
import com.eschool.model.Course;

public class ClassDataModel extends ListDataModel<Clas> implements SelectableDataModel<Clas>, Serializable {  

    public ClassDataModel() {
    }

    public ClassDataModel(List<Clas> data) {
        super(data);
    }
    
    @Override
    public Clas getRowData(String rowKey) {
        List<Clas>  classes = (List<Clas>) getWrappedData();
        
		for (Clas clas : classes) {
            if(Integer.toString(clas.getClassId()).equals(rowKey))
                return clas;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(Clas clas) {
        return clas.getClassId();
    }
}